<?php
# Padded 1.0
# By: David Grega, www.Terranika.com
# Based off the Smarty Template Engine and the PAD SDK
######################################################
# Created: 		10 Jun 2006 by David Grega
# Last Updated:	11 Jun 2006 by David Grega - rootkitted@gmail.com

// Load Smarty Template Engine
require '../3rdParty/smarty/libs/Smarty.class.php';

// Load the part of the PAD SDK we will be using
require '../3rdParty/padsdk/php/include/padfile.php';

// Load the download counter
require 'counter.php';

// Grab the PAD File (from GET parameter 'program')
$padfile = $_GET["program"];

// Initialize the Smarty Template Engine
$smarty = new Smarty;

// Some Smarty Settings
$smarty->compile_check = true;
$smarty->debugging = false;

if ($padfile == "index") {
	$doIndex == true;
	$smarty->assign("doIndex",true);
} else {

	// Do crude testing to ensure no one is trying to hack website
	if ((strpos($padfile, "/") == false) AND (strpos($padfile, "\\") == false) AND (strpos($padfile, ".") == false)) {
		// Everything Okay
	} else {
		die();
	}

	// Initialize the actual PAD file for which we are generating the page
	$PAD = new PADFile("../softwareData/padfiles/" . $padfile . ".xml");

	// Load the data from the PAD File
	if ( !$PAD->Load() )
	  echo "Error: Cannot load PAD file.<br>\n";

	// Assign Values for Template
	$smarty->assign("SoftwareTitle",$PAD->XML->GetValue("XML_DIZ_INFO/Program_Info/Program_Name"));
	$smarty->assign("SoftwareVersion",$PAD->XML->GetValue("XML_DIZ_INFO/Program_Info/Program_Version"));
	$smarty->assign("SoftwareDescription",$PAD->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/English/Char_Desc_2000"));
	$smarty->assign("SoftwareKeywords",$PAD->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/English/Keywords"));
	$smarty->assign("SoftwareSlogan",$PAD->XML->GetValue("XML_DIZ_INFO/Program_Descriptions/English/Char_Desc_45"));
	$smarty->assign("SoftwareOrderURL",$PAD->XML->GetValue("XML_DIZ_INFO/Web_Info/Application_URLs/Application_Order_URL"));
	$smarty->assign("SoftwareScreenshotURL",$PAD->XML->GetValue("XML_DIZ_INFO/Web_Info/Application_URLs/Application_Screenshot_URL"));
	$smarty->assign("SoftwareIconURL",$PAD->XML->GetValue("XML_DIZ_INFO/Web_Info/Application_URLs/Application_Icon_URL"));
	$smarty->assign("SoftwareDownloadURL",$PAD->XML->GetValue("XML_DIZ_INFO/Web_Info/Download_URLs/Primary_Download_URL"));
	$smarty->assign("SoftwareDistribution",$PAD->XML->GetValue("XML_DIZ_INFO/Permissions/Distribution_Permissions"));
	$smarty->assign("SoftwareEULA",$PAD->XML->GetValue("XML_DIZ_INFO/Permissions/EULA"));
	$smarty->assign("SoftwarePrice",$PAD->XML->GetValue("XML_DIZ_INFO/Program_Info/Program_Cost_Dollars"));
	$smarty->assign("SoftwareDLCount",getCount($PAD->XML->GetValue("XML_DIZ_INFO/Program_Info/File_Info/Filename_Long")));
	$smarty->assign("SoftwareSize",$PAD->XML->GetValue("XML_DIZ_INFO/Program_Info/File_Info/File_Size_MB"));
}

// Template to use
$smarty->display('index.tpl');

?>
